using System;
using System.Data;
using System.Collections;

namespace RMAS.DAL
{
    /// <summary>
    /// Summary description for DM_MENU.
    /// </summary>
    public class DM_MENUList : CollectionBase
    {
		private string _ErrMsg;
        public string ErrMsg { get { return _ErrMsg; } }
    	public DM_MENUList()
    	{
	    }

		public void Add(DM_MENU entity)
		{
            this.List.Add(entity);
		}

		public void Add(DM_MENUList list)
		{	
			foreach(DM_MENU entity in list)
			{
				this.Add(entity);
			}
		}
	
		public new virtual Enumerator GetEnumerator()
		{
		    return new Enumerator(this);
		}
		public virtual DM_MENU this[int index]
		{
		    get
			{
				return (DM_MENU)this.List[index];
			}
			set
			{
				this.List[index] = value;
			}
		}

		#region Find Object And List Object
		//---PrimaryKey
	public virtual DM_MENU Find(string PrID)
	{
	    foreach (DM_MENU obj in this.List)
	    {
		if(obj.PrID.ToString().ToUpper().Trim() == PrID.ToString().ToUpper().Trim())
		{
		    obj.IsExisting = true;
		    return obj;
		}
	    }
	    return null;
	}

public virtual DM_MENUList FindListByPrID(string PrID)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
		    if(obj.PrID.ToString().ToUpper().Trim() == PrID.ToString().ToUpper().Trim())
		    {
				List.Add(obj);
		    }
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
    	{
		_ErrMsg = ex.Message;
        		return null;
    	}
}
		//---NonPrimaryKey
        public virtual DM_MENU FindByID(string ID)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.ID.ToString().ToUpper().Trim() == ID.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByPrName(string PrName)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.PrName.ToString().ToUpper().Trim() == PrName.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByPrImage(byte[] PrImage)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.PrImage.ToString().ToUpper().Trim() == PrImage.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByGroupMenuID(string GroupMenuID)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.GroupMenuID.ToString().ToUpper().Trim() == GroupMenuID.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByUnitID1(string UnitID1)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.UnitID1.ToString().ToUpper().Trim() == UnitID1.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByUnitID2(string UnitID2)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.UnitID2.ToString().ToUpper().Trim() == UnitID2.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByNumber(double Number)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.Number.ToString().ToUpper().Trim() == Number.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByPrVAT(double PrVAT)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.PrVAT.ToString().ToUpper().Trim() == PrVAT.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByPrMadeIn(string PrMadeIn)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.PrMadeIn.ToString().ToUpper().Trim() == PrMadeIn.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByPrPrice_Purchase(decimal PrPrice_Purchase)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.PrPrice_Purchase.ToString().ToUpper().Trim() == PrPrice_Purchase.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByPrPrice_AfterVAT(decimal PrPrice_AfterVAT)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.PrPrice_AfterVAT.ToString().ToUpper().Trim() == PrPrice_AfterVAT.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByPrPrice_RetailSale(decimal PrPrice_RetailSale)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.PrPrice_RetailSale.ToString().ToUpper().Trim() == PrPrice_RetailSale.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByPrPrice_WholeSale(decimal PrPrice_WholeSale)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.PrPrice_WholeSale.ToString().ToUpper().Trim() == PrPrice_WholeSale.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByNote(string Note)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.Note.ToString().ToUpper().Trim() == Note.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByUserNameCreate(string UserNameCreate)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.UserNameCreate.ToString().ToUpper().Trim() == UserNameCreate.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByDateCreate(DateTime DateCreate)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.DateCreate.ToString().ToUpper().Trim() == DateCreate.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByIDPOS(string IDPOS)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.IDPOS.ToString().ToUpper().Trim() == IDPOS.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByIsUse(bool IsUse)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.IsUse.ToString().ToUpper().Trim() == IsUse.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_MENU FindByIsDelete(bool IsDelete)
        {
	        foreach (DM_MENU obj in this.List)
	        {
		        if(obj.IsDelete.ToString().ToUpper().Trim() == IsDelete.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

public virtual DM_MENUList FindListByID(string ID)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.ID.ToString().ToUpper().Trim() == ID.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByPrName(string PrName)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.PrName.ToString().ToUpper().Trim() == PrName.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByPrImage(byte[] PrImage)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.PrImage.ToString().ToUpper().Trim() == PrImage.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByGroupMenuID(string GroupMenuID)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.GroupMenuID.ToString().ToUpper().Trim() == GroupMenuID.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByUnitID1(string UnitID1)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.UnitID1.ToString().ToUpper().Trim() == UnitID1.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByUnitID2(string UnitID2)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.UnitID2.ToString().ToUpper().Trim() == UnitID2.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByNumber(double Number)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.Number.ToString().ToUpper().Trim() == Number.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByPrVAT(double PrVAT)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.PrVAT.ToString().ToUpper().Trim() == PrVAT.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByPrMadeIn(string PrMadeIn)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.PrMadeIn.ToString().ToUpper().Trim() == PrMadeIn.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByPrPrice_Purchase(decimal PrPrice_Purchase)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.PrPrice_Purchase.ToString().ToUpper().Trim() == PrPrice_Purchase.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByPrPrice_AfterVAT(decimal PrPrice_AfterVAT)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.PrPrice_AfterVAT.ToString().ToUpper().Trim() == PrPrice_AfterVAT.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByPrPrice_RetailSale(decimal PrPrice_RetailSale)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.PrPrice_RetailSale.ToString().ToUpper().Trim() == PrPrice_RetailSale.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByPrPrice_WholeSale(decimal PrPrice_WholeSale)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.PrPrice_WholeSale.ToString().ToUpper().Trim() == PrPrice_WholeSale.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByNote(string Note)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.Note.ToString().ToUpper().Trim() == Note.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByUserNameCreate(string UserNameCreate)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.UserNameCreate.ToString().ToUpper().Trim() == UserNameCreate.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByDateCreate(DateTime DateCreate)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.DateCreate.ToString().ToUpper().Trim() == DateCreate.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByIDPOS(string IDPOS)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.IDPOS.ToString().ToUpper().Trim() == IDPOS.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByIsUse(bool IsUse)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.IsUse.ToString().ToUpper().Trim() == IsUse.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_MENUList FindListByIsDelete(bool IsDelete)
{
	try
	{
		DM_MENUList List = new DM_MENUList();
		foreach (DM_MENU obj in this.List)
		{
			if(obj.IsDelete.ToString().ToUpper().Trim() == IsDelete.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}
		#endregion
     
		#region Inner Classes
		/// <summary>
		/// Type-specific enumeration class, used by LogCollection.GetEnumerator.
		/// </summary>
		public class Enumerator : IEnumerator
		{
			private IEnumerator wrapped;

			public Enumerator(DM_MENUList collection)
			{
				this.wrapped = ((CollectionBase)collection).GetEnumerator();
			}

			public DM_MENU Current
			{
				get
				{
					return (DM_MENU)(this.wrapped.Current);
				}
			}

			object IEnumerator.Current
			{
				get
				{
					return (DM_MENU)(this.wrapped.Current);
				}
			}

			public bool MoveNext()
			{
				return this.wrapped.MoveNext();
			}

			public void Reset()
			{
				this.wrapped.Reset();
			}
      }
      #endregion  
   }
}